<template>
  <div id="main">
    <div v-for="(item,index) in shop" :key="item.id" class="box">
      <img :src=image[index] alt />
      <p class="name">{{item.name}}</p>
      <span class="num">{{item.num}}</span>
      <div class="price">
        <span>礼拜五价:</span>
        <strong>￥ {{item.price}}</strong>
      </div>
    </div>
  </div>
</template>
<script>
export default {
    data(){
        return{
            shop:[],
            image:[]
        }
    },
    created(){
        var _this = this;
        const url="http://localhost:3000";
        this.$axios.post(url+"/index/swipernav").then(function(response){
            // window.console.log(response)
            //  window.console.log(response.data.code)
            if(response.data.code==200){
                const list = response.data.result
                _this.shop = list;
                for(var i=0;i<list.length;i++){
                    _this.image.push(require("../assets/images"+list[i].image))
                }
            }
        }).catch(function(error){
            window.console.log(error)
        })
    }
}
</script>
<style scoped>
#main{
    width:80%;
    margin: auto;
    text-align: center;
    display: flex;
    justify-content: space-between;
    margin-bottom:20px;
}
.box{
    width:23%;
    background:#f8f6f7;
}
.box img{
    width:100%;
    height:150px;
}
.name{
    font-size: 16px;
    margin:0px;
    padding: 0px;
     margin-top:7px;
}
.num{
    display: inline-block;
    font-size: 14px;
    color:#666;
    margin-top:10px;
}
.price {
    font-size:14px;
    color:#f29d55;
    margin-top:10px;
    margin-bottom: 3
    0px; 
}
.price strong{
    color:#f57
}
</style>